import {usePermissionStore} from "@/store/permission.store.js";

export default {
    name: "permission",
    inserted(el, binding) {
        let perm = binding.value;
        console.log(perm);
        if (!perm) return;
        console.log(el);
    },
    mounted(el, binding) {
        let perm = binding.arg
        let val = binding.value
        let has = usePermissionStore().hasPermission(perm);
        if(!has){
            el.parentNode.removeChild(el)
        }
    },
    updated(el, binding) {
        let perm = binding.arg
        let val = binding.value
        let has = usePermissionStore().hasPermission(perm);
        if(!has&&el.parentNode){
            el.parentNode.removeChild(el)
        }
    }
};
